Collection = function()
{
    this.array = new Array();
   
    this.get = function (id)
    {
        return this.array[id];
    };
    
	this.add = function(item)
    {
        if( !this.contains ( item ) ) 
	   		this.array[this.array.length] = item;
    };
	
	this.addAt = function( id, item )
	{ 
		this.array.splice( id, 0, item );
	};
	
	this.remove = function ( item )
	{
		if( this.contains ( item ) )
			this.array.splice( this.indexOf( item ), 1 );
	};
	
	this.contains = function ( item )
	{
		return this.indexOf( item ) != -1;
	};
	
	this.indexOf = function ( item )
	{
		var l = this.array.length;
		
		while ( l-- )
		{
			if( this.array[ l ] == item )
				return l; 
		}
		return l;
	};
	
	this.iterator = function( id )
    {
        return new Iterator(this, id);
    }
   
    this.size = function()
    {
        return this.array.length;
    };
}

Iterator = function ( collection, id )
{
    this.index = id || 0;
    this.collection = collection;
    this.next = function()
    {
        return this.collection.array[this.index++];
    }
    this.hasNext = function()
    {
        return this.index < this.collection.size();
    }
}
